define(function(require, exports){
	var $ = require("jquery");
	var pubjs = require('pubjs');
	var view  = require('@base/view');

	var SaveNotify = view.container.extend({
		init:function(config){
			config = pubjs.conf(config, {
				'class': 'M-formNotify',
				'url': '',
				'param': null,
				'view_model': {
					'title': LANG('保存成功!'),
					'desc': LANG('您所操作的创意包已成功保存，您现在可以为其添加对应的落地页。'),
					'list_title': LANG('填写说明：'),
					'list': [],
					'buttons': [],
					'operate': this.vmOperate
				}
			});

			this.Super('init', arguments);
		},
		afterBuild:function(){
			var self = this;
			var el = self.getDOM();
			this.hide();

			$([
				'<div class="M-formNotifyContentTitle"></div>',
				'<div class="M-formNotifySuccessImage mt20"><b></b></div>',
				'<div class="M-formNotifyTitle">{{title}}</div>',
				'<div class="M-formNotifyDesc mt10">',
					'<div class="desc">{{desc}}</div>',
					'<span class="listTitle">{{list_title}}</span>',
					'<ul class="list" >',
						'<li ms-repeat-item="list">{{item}}</li>',
					'</ul>',
				'</div>',
				'<div class="M-formNotifyOperate mt20" >',
					'<input ms-repeat-but="buttons" type="button" class="mr10 btn btn-default" ms-click="operate(but.type)" ms-value="but.name"/>',
				'</div>'
			].join('')).appendTo(el);

			this.buildFromTemplate();
		},
		vmOperate: function(type){
			this.fire('saveNotifyOperate', {type: type});
		},
		setDesc: function(desc){
			var vm = this.vm.$;
			vm.desc = desc;
		},
		setList: function(list){
			var vm = this.vm.$;
			vm.list = list;
		},
		// 设置内容标题
		setContentTitle: function(title){
			var self = this;
			var el = this.getDOM();
			var content = el.find('.M-formNotifyContentTitle');
			content.html('');
			if(title){
				content.html(title);
			}
			return self;
		}
	});

	exports.saveNotify = SaveNotify;

});
